﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/SacNetUg.Master" Inherits="System.Web.Mvc.ViewPage<SacNetUG.Models.TeamUserViewModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Create
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<script src="/Scripts/MicrosoftAjax.js" type="text/javascript"></script>
<script src="/Scripts/MicrosoftMvcAjax.js" type="text/javascript"></script>  
<script type="text/javascript">
    function showUserEdit(){
        CKEDITOR.replace('memberBio', { height: "250", width: "600" });
        document.getElementById("userList").style.display = "none";
    }

    function ckeditValue() {
        var editor_data = CKEDITOR.instances.memberBio.getHTML();
        document.forms[0].txtArea.value = editor_data;
    }
    
</script>

<script type="text/javascript">
    function updateWfStep(step) {
        resetWfSteps();
        
        var id = "wfStep" + step;
        document.getElementById(id).style.fontWeight = "bold";
        document.getElementById(id).style.color = "black";

        var msg = "";
        switch (step) {
            case 1:
                msg = "Please select a user to add as a team member";
                break;
            case 2:
                msg = "Enter team member details";
                break;
            case 3:
                msg = "Preview new item";
                break;
            default:
                break;
        }
        
        var node = document.getElementById("wfMessage");
        node.firstChild.nodeValue = msg;
        
    }
    function resetWfSteps() {
        document.getElementById("wfStep1").style.fontWeight = "normal";
        document.getElementById("wfStep2").style.fontWeight = "normal";
        document.getElementById("wfStep3").style.fontWeight = "normal";
        document.getElementById("wfStep1").style.color = "#696969";
        document.getElementById("wfStep2").style.color = "#696969";
        document.getElementById("wfStep3").style.color = "#696969";
    }
    function userLinkClick(id, userName) {
//        alert(id);
//        document.forms[0].nextButton.value = "Next";
        //        document.forms[0].userIdValue.value = id;
        document.forms[0].action = "WfHandler?newUserId=" + id;
        //document.forms[0].nextButton.click();
//        var div = document.getElementById("wfForm");
//        var newHeader = document.createElement("h3");
//        var newText = document.createTextNode("Convert " + userName + " to a Team member");
//        newHeader.appendChild(newText);
//        div.insertBefore(newHeader, div.firstChild);
//        alert(userName);
        //
        var prompt = document.getElementById("userNamePrompt");
        prompt.innerHTML = "Add " + userName + " as a Team member";
        
        //document.forms[0].submit();
        
    }
    
    
    
</script>

<div id="wfHints">

    <span id="wfStep1">1. Select user</span>
    &nbsp; > &nbsp;
    <span id="wfStep2">2. Enter Details</span>
    &nbsp; > &nbsp;
    <span id="wfStep3">3. Preview</span>
    <br />
    
    <h3 id="wfMessage">Please select a user to add as a team member</h3>
    
<%--    <input type='button' onclick='updateWfStep(1)' value='Next'/>
    <input type='button' onclick='updateWfStep(2)' value='Next'/>
    <input type='button' onclick='updateWfStep(3)' value='Next'/>--%>


</div>

    <div id="userList">
        <% Html.RenderPartial("UserList", ViewData["UserList"]); %>
    </div>
    <br />

    <div id="userDetails">
    
    </div>
    <div id="wfForm">
        <h3 id="userNamePrompt"></h3>
        <%--<%= Ajax.ActionLink("test", "WfHandler", new { wfStep = (int)ViewData["wfStep"] + 1 }, new AjaxOptions { UpdateTargetId = "dummy"})%>--%>
        <% Ajax.BeginForm("WfHandler",new AjaxOptions { UpdateTargetId = "wfForm", OnSuccess  = "showUserEdit"}); %>
            <%{ %>
            
            <input type="hidden" id="wfStepValue" name="wfStepValue" value='<%= ViewData["wfStep"] %>' />
            <input type="hidden" id="userIdValue" name="userIdValue" />
            <%--<input type="submit" value="Cancel" onclick='document.getElementById("wfStepValue").value = <%= (int)ViewData["wfStep"] - 1 %>; document.forms[0].submit();'   />
            <input type="submit" value="Next" onclick='document.getElementById("wfStepValue").value = <%= (int)ViewData["wfStep"] + 1 %>; document.forms[0].submit();'  />--%>
            <input type="submit" value="Cancel" name="cancelButton"/>
            <input type="submit" value="Next" name="nextButton" />
                          
                        <%} %>

    </div>

    <div>
        <%--<%= Ajax.ActionLink("AjaxLink", "AjaxUserList", "Team", new AjaxOptions { UpdateTargetId = "userList" })%>--%>
        <%--<%= Ajax.ActionLink("AjaxLink", "AjaxUserList", "Team", new AjaxOptions { UpdateTargetId = "ajaxContent"})%>--%>
        <br />
        <%=Html.ActionLink("Back to List", "Index")%>
        <br />
        <%=Html.ActionLink("test", "WfHandler", new { wfStep = (int)ViewData["wfStep"] + 1 })%>
        
    </div>
    <div id="dummy">
        
    </div>

</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="head" runat="server">
<script src="../../../CkEditor/ckeditor.js" type="text/javascript"></script>
</asp:Content>

